package com.atguigu.gulimall.cart.vo;

import java.math.BigDecimal;
import java.util.List;

/**
 * 整个购物车
 */
public class CartVo {
    /**
     * 购物车子项信息
     */
    List<CartItemVo> items;

    /**
     * 商品数量
     */
    private Integer countNum;

    /**
     * 商品类型数量
     */
    private Integer countType;

    /**
     * 商品总价
     */
    private BigDecimal totalAmount;

    public List<CartItemVo> getItems() {
        return items;
    }

    public void setItems(List<CartItemVo> items) {
        this.items = items;
    }

    public Integer getCountNum() {
        int count = 0;
        if(this.items != null && this.items.size()>0){
            for (CartItemVo item : this.items) {
                count += item.getCount();
            }
        }

        return count;
    }

    public Integer getCountType() {
        return this.items.size();
    }

    public BigDecimal getTotalAmount() {
        BigDecimal amount = new BigDecimal("0");
        if(this.items != null && this.items.size()>0){
            for (CartItemVo item : this.items) {
                amount.add(item.getTotalPrice());
            }
        }

        return amount;
    }
}
